using System;
using System.Collections.Generic;
using System.Text;

namespace Common.Utilities.NetworkUtilities 
{
    /// <summary>
    /// 
    /// </summary>
    public class NetworkShareMap
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="mFilePath"></param>
        /// <returns></returns>
        public static string getUNCPath(string mFilePath)
        {
            if (mFilePath != null && mFilePath.Length > 0)
            {
                string uncPath = ShareCollection.PathToUnc(mFilePath);
                int pos = uncPath.IndexOf("\\\\");
                int pos2 = uncPath.IndexOf("\\", pos + 2);
                if(pos>=0 && pos2>0)
                {
                    string machineName = uncPath.Substring(pos + 2, pos2 - pos - 2);
                    if(machineName.ToLower()==Environment.MachineName.ToLower())
                    {
                        uncPath = mFilePath;
                    }
                }
                return uncPath;
            }
            else
            {
                return "";
            }
        }
    }
}
